package ro.victordramba.scriptarea
{
  import flash.display.Shape;
  import flash.display.Sprite;
  import flash.utils.setInterval;

  internal class ScriptCursor extends Sprite
  {
    public static var height:int;
    private var crs:Shape;
    
    public function ScriptCursor()
    {
      setInterval(redraw, 500);
      crs = new Shape;
      addChild(crs);
    }
    
    private function redraw():void
    {
      b = !b;
      crs.graphics.clear();
      if (b)
      {
        crs.graphics.beginFill(0, 1);
        crs.graphics.drawRect(0, 0, 2, ScriptCursor.height);
      }
    }
    
    public function pauseBlink():void
    {
      b = false;
      redraw();
      b = false;
    }
    
    public function setSize(w:int, h:int):void
    {
      graphics.clear();
      graphics.beginFill(0, .1);
      graphics.drawRect(0, 0, w, h);
      graphics.endFill();
    }
    
    public function setX(x:int):void
    {
      crs.x = x;
    }
    
    public function getX():int
    {
      return crs.x;
    }
    
    private var b:Boolean = true;
  }
}